layui.use(["fsConfig", "fsCommon"], function () {
    var layer = layui.layer,
        fsCommon = layui.fsCommon,
        fsConfig = layui.fsConfig,
        jumpLogin = $.result(fsConfig, "filters.401");

    var token = localStorage.getItem('cdce_serivce_token');
    if (token === "") {
        jumpLogin()
    }

    function callback(data) {
        $(".name").text(data.user.name);
        if (data.user.gender) {
            $(".gender").text("男");
        } else {
            $(".gender").text("女");
        }
        $(".registraton_number").text(data.user.registraton_number);
        $(".student_id").text(data.user.student_id);
        var certificate_type = "";
        switch (data.user_detail.certificate_type) {
            case "SPECIALTY":
                certificate_type = "国民教育 专科";
                break;
            case "NONE":
                certificate_type = "无";
                break;
        }
        $(".certificate_type").text(certificate_type);
        var student_status = "";
        switch (data.user_detail.student_status) {
            case "STUDYING":
                student_status = "学习中";
                break;
            case "UNDERGRADUATE":
                student_status = "肄业";
            case "GRADUATE":
                student_status = "毕业";
                break;
        }
        $(".student_status").text(student_status);

        var occupation_status = "";
        switch (data.user_detail.occupation_status) {
            case "UNWORKING":
                occupation_status = "未工作";
                break;
            case "WORKING":
                occupation_status = "工作";
        }
        $(".occupation_status").text(occupation_status);

        var cultivation_level = "";
        switch (data.user_detail.cultivation_level) {
            case "JUNIOR_COLLEGE":
                cultivation_level = "高启专";
                break;
            case "COLLEGE_UPGRADE":
                cultivation_level = "专生本";
        }
        $(".cultivation_level").text(cultivation_level)
    }

    fsCommon.get("/desc/v1alpha/info", "", callback);
});